package com.dingquan.springbootdingquan.controller;

import com.dingquan.springbootdingquan.pojo.Dto.UserDto;
import com.dingquan.springbootdingquan.services.IServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IServices UserServices;


    @PostMapping
    public String  add(@RequestBody  UserDto user){
        UserServices.add(user);
        return "success!";
    }
    @PutMapping
    public String update(@RequestBody UserDto user){
        UserServices.update(user);
        return "success!";
    }
    @GetMapping("/{userId}")    //"/{userId}"
    public String select (@PathVariable  Integer userId){
        UserServices.select(userId);
        return "success!";
    }
    @DeleteMapping("/{userId}")
    public String delete(@PathVariable Integer userId){
        UserServices.delete(userId);
        return "success!";
    }
}
